﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Engine.Classes {
    import flash.events.*;
    import flash.media.*;

    public class SoundObject {

        public var sound:Sound;
        protected var m_reloop:Boolean = false;
        protected var m_soundChannel:SoundChannel;
        protected var m_pausePoint:Number = 0;
        protected var m_isPaused:Boolean = false;
        protected var m_loops:Number = 0;
        protected var m_transform:SoundTransform = null;
        public var isMusic:Boolean = false;

        public function SoundObject(_arg1:Sound, _arg2:SoundChannel, _arg3:Number=0, _arg4:SoundTransform=null){
            this.sound = _arg1;
            this.m_loops = _arg3;
            this.m_reloop = (this.m_loops > 0);
            this.m_transform = _arg4;
            this.m_soundChannel = _arg2;
            this.m_soundChannel.addEventListener(Event.SOUND_COMPLETE, this.onComplete);
        }
        public function get loops():Number{
            return (this.m_loops);
        }
        public function set loops(_arg1:Number):void{
            this.m_loops = _arg1;
        }
        public function set volume(_arg1:Number):void{
            var _local2:SoundTransform = new SoundTransform(_arg1, this.pan);
            this.m_soundChannel.soundTransform = _local2;
        }
        public function get volume():Number{
            return (this.m_soundChannel.soundTransform.volume);
        }
        public function set pan(_arg1:Number):void{
            var _local2:SoundTransform = new SoundTransform(this.volume, _arg1);
            this.m_soundChannel.soundTransform = _local2;
        }
        public function get pan():Number{
            return (this.m_soundChannel.soundTransform.pan);
        }
        public function get position():Number{
            return (this.m_soundChannel.position);
        }
        public function isPlaying():Boolean{
            return ((this.m_isPaused == false));
        }
        public function canReloop():Boolean{
            var _local1:Boolean = this.m_reloop;
            this.m_reloop = false;
            return (_local1);
        }
        public function pause():void{
            if (this.m_isPaused == false){
                this.m_pausePoint = this.m_soundChannel.position;
                this.m_soundChannel.stop();
                this.m_isPaused = true;
            };
        }
        public function unpause():void{
            if (this.m_isPaused){
                this.m_isPaused = false;
                this.m_soundChannel = this.sound.play(this.m_pausePoint, (this.isMusic) ? 999999 : 0, this.m_soundChannel.soundTransform);
                this.m_pausePoint = 0;
            };
        }
        public function stop(_arg1:Boolean=true):void{
            this.m_soundChannel.stop();
            if (_arg1){
                this.m_reloop = false;
                this.sound.dispatchEvent(new Event(Event.SOUND_COMPLETE));
            };
        }
        private function onComplete(_arg1:Event):void{
            this.sound.dispatchEvent(new Event(Event.SOUND_COMPLETE));
        }

    }
}//package Engine.Classes 
